import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author Stringzhua
 * @Date 2024/11/4 11:18
 * description:
 */
public class DeadLock {
    private final Object loclA = new Object();
    private final Object loclB = new Object();

    public void add() throws InterruptedException {
        synchronized (loclA) {//获取lockA的锁
            Thread.sleep(100);
            synchronized (loclB) {//获取lockB的锁
                System.out.println("执行add");
            }//释放lockB
        }//释放lockA
    }

    public void dec(){
        synchronized (loclB){//获取lockB的锁
            synchronized (loclA){//获取lockA的锁
                System.out.println("执行dec");
            }//释放lockA
        }//释放lockB
    }
}
